﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TarreOA.TarreOABLL;
using TarreOA.TarreOAModels;

public partial class Bottom : System.Web.UI.Page
{
    public string msg_url;
    public string email_url;
    public string workflow_url;

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void AwokeTimer_Tick(object sender, EventArgs e)
    {
        if (Session["user"] == null) 
        {
            Response.Redirect("~/Message.aspx");
        }

        User curLoginUser = (User)Session["user"];
        List<object> list_msg = MessageAwoke.Instance().GetValuesFromKeyForShortMsg(curLoginUser.LoginName);
        if (list_msg != null && list_msg.Count > 0)
        {
            this.AwokeImage.Visible = true;
            int msg_id = (int)list_msg[0];
            this.msg_url = "User/UserNote/MsgToShow.aspx?mid=" + msg_id;
            ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "msgPlay(" + list_msg.Count + ");", true);
        }
        else
        {
            this.AwokeImage.Visible = false;
        }
        List<object> list_emai = MessageAwoke.Instance().GetValuesFromKeyForEmail(curLoginUser.LoginName);
        if (list_emai != null && list_emai.Count > 0)
        {
            this.AwokeImage2.Visible = true;
            int email_id = (int)list_emai[0];
            this.email_url = "User/UserEmail/EmailToShow.aspx?eid=" + email_id;
            ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "mailPlay(" + list_emai.Count + ");", true);
        }
        else
        {
            this.AwokeImage2.Visible = false;
        }
        List<object> list_workflow = MessageAwoke.Instance().GetValuesFromKeyForWorkFlow(curLoginUser.LoginName);
        if (list_workflow != null && list_workflow.Count > 0)
        {
            this.AwokeImage3.Visible = true;
            int work_id = (int)list_workflow[0];
            this.workflow_url = "Flow_Info/Index.aspx";
        }
        else
        {
            this.AwokeImage3.Visible = false;
        }
    }
}